<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="deviceList"  fitColumns="true" title="设备信息" actionUrl="deviceAppointApplyController.do?deviceAppointListData" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="30"></t:dgCol> 
   <t:dgCol title="设备编号"  field="deviceNO"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="RFID号"  field="rfidNo"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="名称"  field="name"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="品牌"  field="brand.brandName"   query='true' queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="型号"  field="model.modelName"   query='true' queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="存放地"  field="storage"    queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="开始开放时间"  field="openTimeBegin" formatter="yyyy-MM-dd hh:mm"   queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="结束开放时间"  field="openTimeEnd" formatter="yyyy-MM-dd hh:mm"   queryMode="single"  width="120"></t:dgCol>  
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgFunOpt funname="createApply(id)" title="申请预约" ></t:dgFunOpt>  
     
   </t:datagrid>
  </div>
 </div>
 <script type="text/javascript">
 
 	function createApply(id,index){
 		$.dialog({
			content: 'url:deviceAppointApplyController.do?goAdd&deviceId='+id,
			zIndex: 30,
			lock : true,
			width:440,
			height: 300,
			title:'预约申请',
			opacity : 0.3,
			cache:false, 
			ok: function(){
				iframe = this.iframe.contentWindow;
				
				var rows = $('#deviceList').datagrid('getRows');
				var rec = rows[index]; 
				var openTimeEnd = rec.openTimeEnd;
				openTimeEnd = openTimeEnd.replace(/-/g,"/");
				openTimeEnd = new Date(openTimeEnd);
				
				var openTimeBegin = rec.openTimeBegin.replace(/-/g,"/");
				openTimeBegin = new Date(openTimeBegin);
				
				var result = iframe.validateInfo(openTimeBegin,openTimeEnd);
				if(result){
					 $('#btn_sub', iframe.document).click(); 
				}  
 				return false;
			},
			okVal:'保存申请',
		    cancelVal: '关闭',
		    cancel: true /*为true等价于function(){}*/
		});
 	} 
 
 </script>